<?php

/**
 * This is the model class for table "{{apply}}".
 *
 * The followings are the available columns in table '{{apply}}':
 * @property string $aid
 * @property string $type
 * @property string $from_uid
 * @property string $to_gid
 * @property string $reason
 * @property string $operator_uid
 * @property string $create_time
 * @property string $last_modify_time
 * @property string $status
 */
class ApplyData extends CActiveRecord
{
    /**
     * Returns the static model of the specified AR class.
     * @return ApplyDao the static model class
     */
    public static function model($className=__CLASS__)
    {
        return parent::model($className);
    }

    /**
     * @return string the associated database table name
     */
    public function tableName()
    {
        return '{{apply}}';
    }

    /**
     * @return array validation rules for model attributes.
     */
    public function rules()
    {
        // NOTE: you should only define rules for those attributes that
        // will receive user inputs.
        return array(
            array('type, from_uid, to_gid, create_time, last_modify_time', 'required'),
            array('type, from_uid, to_gid, operator_uid, create_time, last_modify_time, status', 'length', 'max'=>10),
            array('reason', 'length', 'max'=>50),
            // The following rule is used by search().
            // Please remove those attributes that should not be searched.
            array('aid, type, from_uid, to_gid, reason, operator_uid, create_time, last_modify_time, status', 'safe', 'on'=>'search'),
        );
    }

    /**
     * @return array relational rules.
     */
    public function relations()
    {
        // NOTE: you may need to adjust the relation name and the related
        // class name for the relations automatically generated below.
        return array(
        );
    }

    /**
     * @return array customized attribute labels (name=>label)
     */
    public function attributeLabels()
    {
        return array(
            'aid' => 'Aid',
            'type' => 'Type',
            'from_uid' => 'From Uid',
            'to_gid' => 'To Gid',
            'reason' => 'Reason',
            'operator_uid' => 'Operator Uid',
            'create_time' => 'Create Time',
            'last_modify_time' => 'Last Modify Time',
            'status' => 'Status',
        );
    }

    /**
     * Retrieves a list of models based on the current search/filter conditions.
     * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
     */
    public function search()
    {
        // Warning: Please modify the following code to remove attributes that
        // should not be searched.

        $criteria=new CDbCriteria;

        $criteria->compare('aid',$this->aid,true);
        $criteria->compare('type',$this->type,true);
        $criteria->compare('from_uid',$this->from_uid,true);
        $criteria->compare('to_gid',$this->to_gid,true);
        $criteria->compare('reason',$this->reason,true);
        $criteria->compare('operator_uid',$this->operator_uid,true);
        $criteria->compare('create_time',$this->create_time,true);
        $criteria->compare('last_modify_time',$this->last_modify_time,true);
        $criteria->compare('status',$this->status,true);

        return new CActiveDataProvider(get_class($this), array(
            'criteria'=>$criteria,
        ));
    }
}
